package com.tianqu.tms.www.permission.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsAction;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.www.permission.controller.PermissionListTopController;
import com.tianqu.tms.www.permission.viewhelper.PermissionManageViewHelper;

/**
 * @author zhangxueliang
 * 权限一览列表action
 */
public class PermissionListTopAction extends TmsAction{
	private Logger logger = Logger.getLogger(PermissionListTopAction.class);
	@SuppressWarnings("unchecked")
	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws Exception {
		logger.debug(this.getClass().getName() + "#execute was called.");
		PermissionListTopController controller = new PermissionListTopController();
		controller.execute(uc);
		PermissionManageViewHelper viewhelper = new PermissionManageViewHelper();
		List allRoleList = (List)uc.getAttribute(PermissionListTopController.ALLROLELIST);
		viewhelper.setAllRoleList(allRoleList);
		uc.setAttribute(TmsConstants.VIEWHELP, viewhelper);
		uc.removeAttribute("role");
		request.setAttribute("viewhelp", viewhelper);
		logger.debug(this.getClass().getName() + "#execute was completed.");
		return mapping.findForward(TmsConstants.SUCCESS);
	}

}
